package main

import (
	"fmt"
	"github.com/beego/beego/v2/client/orm"
	_ "github.com/beego/beego/v2/core/config/yaml"
	beego "github.com/beego/beego/v2/server/web"
	_ "github.com/go-sql-driver/mysql"
	"personal-skill/db"
	"personal-skill/models"
	_ "personal-skill/routers"
)

func init() {
	mysqlConfig := db.GetMysqlConfig()
	_ = orm.RegisterDataBase(mysqlConfig.GetAliasName(), mysqlConfig.GetDriverName(), mysqlConfig.GetUrl())
	orm.RegisterModel(new(models.Application), new(models.Field), new(models.Major), new(models.Menu), new(models.Role), new(models.Skill), new(models.User))
	err := orm.RunSyncdb(mysqlConfig.GetAliasName(), false, true)
	if err != nil {
		fmt.Println(err.Error())
	}

}
func main() {
	orm.Debug = true
	beego.Run()
}
